package logic

import (
	"context"
	"video-joy/models/mysql"

	"video-joy/userrpc/internal/svc"
	"video-joy/userrpc/userrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoShowLogic {
	return &VideoShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 视频详情
func (l *VideoShowLogic) VideoShow(in *userrpc.VideoShowRequest) (*userrpc.VideoShowResponse, error) {
	// todo: add your logic here and delete this line

	var video mysql.VideoInfo

	if err := video.VideoById(mysql.DB, in.VideoId); err != nil {
		return nil, err
	}

	return &userrpc.VideoShowResponse{
		UserId:        video.UserId,
		VideoTitle:    video.VideoTitle,
		VideoCategory: video.VideoCategory,
		VideoLink:     video.VideoLink,
		CoverLink:     video.CoverLink,
		VideoIntro:    video.VideoIntro,
		PlayNum:       int64(video.PlayNum),
		LikeNum:       int64(video.LikeNum),
		CollectNum:    int64(video.CollectNum),
		VideoStatus:   int64(video.VideoStatus),
		TopicId:       int64(video.TopicId),
	}, nil
}
